package com.xm.service.background;

import com.xm.dao.background.CommodityGiftsDao;
import com.xm.entity.CommodityGifts;
import com.xm.exception.SqlErrorException;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 康文程
 * @date 2024-1-16 下午 07:44
 */
public class CommodityGiftsService {
    private final CommodityGiftsDao dao = new CommodityGiftsDao();
    /**
     * 根据commodity_gifts_id修改gifts_number
     * @param commodityGiftsId 商品礼品Id
     * @param giftsNumber 礼品数量
     * @return 修改成功返回true，失败返回false
     * @throws SqlErrorException SQL执行异常
     */
    public boolean updateGiftsNumberById(Integer commodityGiftsId, Integer giftsNumber) throws SqlErrorException {
        return dao.updateGiftsNumberById(commodityGiftsId, giftsNumber);
    }
    /**
     * 查询commodity_gifts表和commodity表联合查询结果
     * @return 包含commodity_gifts_id和commodity_name的结果集对象列表，如果不存在则返回空列表
     * @throws SqlErrorException SQL执行异常
     */
    public List<CommodityGifts> queryCommodityGiftsAndCommodity() throws SQLException {
        return dao.queryCommodityGiftsAndCommodity();
    }
}
